<?php

namespace Home\Model\Ajax;

class TagSo extends AbstractAjax
{
    public function handle()
    {
        $key = I('request.tagkey', '', 'trim');
        if (empty($key)) {
            $ajax['status']  = 0;
            $ajax['content'] = '关键字不能为空';
            return $ajax;
        }
        $map['tag']      = array('LIKE', '%' . $key . '%');
        $sort            = 'sort DESC, count_question DESC';
        $list            = D('Tag')->where($map)->order($sort)->limit(5)->select();
        $ajax['status']  = 1;
        $ajax['content'] = $list;
        $ajax['count']   = count($list);
        $ajax['key']     = $key;
        return $ajax;
    }
}